package com.yhj.wchat.service.impl;

import java.util.List;

import javax.annotation.Resource;

import com.yhj.wchat.entity.query.PageSize;
import com.yhj.wchat.mapper.UserContactApplyNewMapper;
import org.springframework.stereotype.Service;


import com.yhj.wchat.entity.query.UserContactApplyNewQuery;
import com.yhj.wchat.entity.po.UserContactApplyNew;
import com.yhj.wchat.entity.vo.PaginationResultVO;
import com.yhj.wchat.entity.query.SimplePage;

import com.yhj.wchat.service.UserContactApplyNewService;
import com.yhj.wchat.utils.StringTools;


/**
 *  业务接口实现
 */
@Service("userContactApplyNewService")
public class UserContactApplyNewServiceImpl implements UserContactApplyNewService {

	@Resource
	private UserContactApplyNewMapper<UserContactApplyNew, UserContactApplyNewQuery> userContactApplyNewMapper;

	/**
	 * 根据条件查询列表
	 */
	@Override
	public List<UserContactApplyNew> findListByParam(UserContactApplyNewQuery param) {
		return this.userContactApplyNewMapper.selectList(param);
	}

	/**
	 * 根据条件查询列表
	 */
	@Override
	public Integer findCountByParam(UserContactApplyNewQuery param) {
		return this.userContactApplyNewMapper.selectCount(param);
	}

	/**
	 * 分页查询方法
	 */
	@Override
	public PaginationResultVO<UserContactApplyNew> findListByPage(UserContactApplyNewQuery param) {
		int count = this.findCountByParam(param);
		int pageSize = param.getPageSize() == null ? PageSize.SIZE15.getSize() : param.getPageSize();

		SimplePage page = new SimplePage(param.getPageNo(), count, pageSize);
		param.setSimplePage(page);
		List<UserContactApplyNew> list = this.findListByParam(param);
		PaginationResultVO<UserContactApplyNew> result = new PaginationResultVO(count, page.getPageSize(), page.getPageNo(), page.getPageTotal(), list);
		return result;
	}

	/**
	 * 新增
	 */
	@Override
	public Integer add(UserContactApplyNew bean) {
		return this.userContactApplyNewMapper.insert(bean);
	}

	/**
	 * 批量新增
	 */
	@Override
	public Integer addBatch(List<UserContactApplyNew> listBean) {
		if (listBean == null || listBean.isEmpty()) {
			return 0;
		}
		return this.userContactApplyNewMapper.insertBatch(listBean);
	}

	/**
	 * 批量新增或者修改
	 */
	@Override
	public Integer addOrUpdateBatch(List<UserContactApplyNew> listBean) {
		if (listBean == null || listBean.isEmpty()) {
			return 0;
		}
		return this.userContactApplyNewMapper.insertOrUpdateBatch(listBean);
	}

	/**
	 * 多条件更新
	 */
	@Override
	public Integer updateByParam(UserContactApplyNew bean, UserContactApplyNewQuery param) {
		StringTools.checkParam(param);
		return this.userContactApplyNewMapper.updateByParam(bean, param);
	}

	/**
	 * 多条件删除
	 */
	@Override
	public Integer deleteByParam(UserContactApplyNewQuery param) {
		StringTools.checkParam(param);
		return this.userContactApplyNewMapper.deleteByParam(param);
	}

	/**
	 * 根据ApplyId获取对象
	 */
	@Override
	public UserContactApplyNew getUserContactApplyNewByApplyId(Integer applyId) {
		return this.userContactApplyNewMapper.selectByApplyId(applyId);
	}

	/**
	 * 根据ApplyId修改
	 */
	@Override
	public Integer updateUserContactApplyNewByApplyId(UserContactApplyNew bean, Integer applyId) {
		return this.userContactApplyNewMapper.updateByApplyId(bean, applyId);
	}

	/**
	 * 根据ApplyId删除
	 */
	@Override
	public Integer deleteUserContactApplyNewByApplyId(Integer applyId) {
		return this.userContactApplyNewMapper.deleteByApplyId(applyId);
	}
}